﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using RearLivestock.Beginning.Api.Application.Command.PrenatalCheckup;
using RearLivestock.Common.Dtos;

namespace RearLivestock.Beginning.Api.Controllers
{
    /// <summary>
    /// 种母妊检控制器
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class PrenatalCheckupController : ControllerBase
    {
        private readonly IMediator _mediator;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public PrenatalCheckupController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 获取妊检结果
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpGet("SearchPregnancyResult")]
        public async Task<Result> SearchPregnancyResult([FromQuery] SearchPregnancyResultCommand cmd)
        {
            return await _mediator.Send(cmd);
        }

        /// <summary>
        /// 获取妊检方式
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpGet("SearchPregnancyType")]
        public async Task<Result> SearchPregnancyType([FromQuery] SearchPregnancyTypeCommand cmd)
        {
            return await _mediator.Send(cmd);
        }

        /// <summary>
        /// 添加种母妊检
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost("CreatePrenatalCheckup")]
        public async Task<Result> CreatePrenatalCheckup(CreatePrenatalCheckupCommand cmd)
        {
            return await _mediator.Send(cmd);
        }

        /// <summary>
        /// 获取种母妊检列表
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost("SearchPrenatalCheckup")]
        public async Task<Result<PageResultDto<PrenatalCheckupDtos>>> SearchPrenatalCheckup(SearchPrenatalCheckupCommand cmd)
        {
            return await _mediator.Send(cmd);
        }

        /// <summary>
        /// 删除种母妊检列表
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPut("DeltedPrenatalCheckup")]
        public async Task<Result> DeltedPrenatalCheckup(DeletedPrenatalCheckupCommand cmd)
        {
            return await _mediator.Send(cmd);
        }

        /// <summary>
        /// 获取种母妊检并赋值
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpGet("DetailPrenatalCheckup")]
        public async Task<Result> DetailPrenatalCheckup([FromQuery] DetailPrenatalCheckupCommand cmd)
        {
            return await _mediator.Send(cmd);
        }

        /// <summary>
        /// 修改种母妊检
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPut("UpdatePrenatalCheckup")]
        public async Task<Result> UpdatePrenatalCheckup(UpdatePrenatalCheckupCommand cmd)
        {
            return await _mediator.Send(cmd);
        }

    }
}
